package com.bo.controller;

import com.bo.anno.Log;
import com.bo.pojo.Result;
import com.bo.utils.AliOSSUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author huangbo
 * @version 1.0.0
 */
@Slf4j
@RestController
public class UploadController {
    @Autowired
    private AliOSSUtils aliOSSUtils;

    @Log
    @PostMapping("/upload")
    public Result upload(MultipartFile image) throws IOException {
        String url = aliOSSUtils.upload(image);
        log.info("文件上传 文件名:{} url:{}",image.getOriginalFilename(),url);
        return Result.success(url);
    }

}
